<!doctype html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>视频管理登录</title>
  <meta name="renderer" content="webkit|ie-comp|ie-stand">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon" />
  <link href="/static/css/font.css?v={{data.version}}" rel="stylesheet">
  <link href="/static/css/weadmin.css?v={{data.version}}" rel="stylesheet">
  <script src="/static/lib/layui/layui.js?v={{data.version}}"></script>

</head>

<body class="login-bg">

<div class="login">
<div class="message">视频管理登录</div>
<div id="darkbannerwrap"></div>

<form method="post" class="layui-form">
  <input name="username" placeholder="用户名" type="text" lay-verify="required" class="layui-input">
  <hr class="hr15">
  <input name="password" lay-verify="required" placeholder="密码" type="password" class="layui-input" autocomplete="off">
  <hr class="hr15">
  <input class="loginin" value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
</form>
</div>

<script type="text/javascript">

layui.extend({
  admin: '{/}./static/js/admin'
});
layui.config({
	base: './static/js/'
	,version: '{{data.version}}'
}).extend({ //设定模块别名
   	admin: 'admin'
	,http: 'http'
});
layui.use(['form', 'admin', 'http','jquery'], function () {
  var form = layui.form
    , admin = layui.admin
    , http = layui.http 
    , $ = layui.jquery;
  //监听提交
  form.on('submit(login)', function (data) {
    $.ajax({
        url: '/user_api/login',
        type: 'POST',
        data: data.field,
        success: function(res) {
          var res = $.parseJSON(res);
          if(res.code === 0){
            localStorage.setItem('username', data.field['username'])
            layer.msg('登录成功，即将跳转~', function () {
              location.href = '/admin'
            });
          }else {
            layer.msg(res.msg, function () {});
          }
        }
      })
    return false;
  });
});   
</script>
</body>

</html>